import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

// 引入 vue-router
import VueRouter from 'vue-router'

// Vue 安装插件
Vue.use(VueRouter)

// 引入 组件
import Index from './views/Index.vue'
import News from './views/News.vue'
import Sport from './views/Sport.vue'

// 引入 二级组件
import SportIndex from './views/second/SportIndex.vue'
import HomeSport from './views/second/HomeSport.vue'
import OutSport from './views/second/OutSport.vue'

// 创建路由规则
let routes = [
  {
    path: '/',
    redirect: '/index'
  },
  {
    path: '/index',
    component: Index
  },
  {
    path: '/news',
    component: News
  },
  {
    path: '/sport',
    component: Sport,
    children: [
      {
        path: '/sport',
        redirect: 'sportindex'
      },
      {
        path: 'sportindex',
        component: SportIndex
      },
      {
        path: 'homesport',
        component: HomeSport
      },
      {
        path: 'outsport',
        component: OutSport
      }
    ]
  }
]

// 根据规则创建路由对象
let router = new VueRouter({
  routes,
  // 设置路由模式不带 # 号的路径
  mode: 'history'
})

// 将路由挂载到 new Vue 的配置对象中
new Vue({
  render: h => h(App),
  router
}).$mount('#app')
